package com.example.library.controller;


import com.example.library.entity.R;
import com.example.library.entity.User;
import com.example.library.service.impl.UserServiceImpl;
import java.util.Collections;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhaoyufei
 * @since 2023-08-07
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserServiceImpl userService;

    @PostMapping("/login")
    public R<User> login(@RequestBody User user) {
        User login = userService.login(user);
        R<User> r = new R<>();
        if (login == null) {
            r.setStatus("201");
        } else {
            r.setStatus("200");
            r.setData(user);
        }
        return r;
    }
}
